<?php
include 'init.php';
unset( $_SESSION[ 'modified' ] );

switch ( $action ) {
    case 'add':
        header( 'Location: edit.php' );
        break;
    case 'filter':
        if ( $_REQUEST[ 'filter_terms' ] != '' ) {
            $_SESSION[ 'filter' ] = sqlite_escape_string( $_REQUEST[ 'filter_terms' ] );
            $contacts = $d->filter_contacts( $_SESSION[ 'filter' ] );
        break;
        } else {
            // If there are no search terms, unset the session variable, and fall through to the default case.
            unset( $_SESSION[ 'filter' ] );
        }
    default:
        $contacts = $d->get_all_contacts( );
        break;
}
include 'templates/header.template.php';
include 'templates/list.template.php';
include 'templates/footer.template.php';

?>
